package com.mckillion.Exercise8;

import java.awt.Color;
import java.util.HashMap;

public class LineFactory {
	@SuppressWarnings("rawtypes")
	private static HashMap linesByColor = new HashMap();
	
	public LineFactory(){
		linesByColor = new HashMap<Color, Line>();
	}
	
	@SuppressWarnings("unchecked")
	public static Line getLineColor(Color color){
		Line l = (Line) linesByColor.get(color);
		if(l == null){
			l = new Line(color);
			linesByColor.put(color, l);
			System.out.println("Creating " + color + " line.");
		}
		return l;
	}
}
